<?php
namespace app\common\validate;
use think\Validate;
use think\Request;
class MemberRealname extends Validate{
    protected $rule =   [
        'cardphoto1'  => 'require',
        'cardphoto2' => 'require',
        'realname' => 'require',
        'idcard'=>'require|min:18',
         // 'phone' => 'require|number|length:11',
        // 'agree' => 'require',
        // 'code' => 'require|checkCode',
    ];

    protected $message  =   [
        'cardphoto1.require' => '身份证正面照不为空',
        'cardphoto2.require' => '身份证反面照不为空',
        'realname.require' => '姓名不为空',
        'idcard.require' => '身份证不为空',
        'idcard.min' => '身份证号码不能少于18位',
     // 'phone.require' => '手机号不为空',
        // 'phone.number'   => '手机号必须是数字',
        // 'phone.length'  => '手机号格式错误',
        // 'agree.require' => '需要同意《用户协议》',
        // 'code' => '验证码不能为空！',
    ];

    protected $scene = [
        'add' => [ 'cardphoto1','cardphoto2','realname', 'idcard'],
    ];
    
    protected function checkCode($value, $rule=[],$data){
        $status = check_sms($data['phone'], $data['code']);
        if (!$status){
            return '验证码输入错误';
        }else{
            return true;
        }
    }
}